home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / OUTPUT / DRAWABLE.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  28.3 KB  |  704 lines

  1.  
  2. package sub_arctic.output;
  3.  
  4. import java.awt.Graphics;
  5. import java.awt.Font;
  6. import java.awt.FontMetrics;
  7. import java.awt.Color;
  8. import java.awt.Point;
  9. import java.awt.Rectangle;
  10. import java.awt.Polygon;
  11. import java.awt.Image;
  12. import java.awt.image.ImageObserver;
  13.  
  14. /** 
  15.  * Specialization of, and wrapper for, Graphics class.<p>
  16.  *
  17.  * This class provides a specialization of the AWT Graphics class that
  18.  * modifies drawing operations slightly to work better with subArctic
  19.  * (e.g., in the area of image drawing), and add some operations for
  20.  * convenience purposes.  <p>
  21.  *
  22.  * Since we don't have access to the construction process for Graphics 
  23.  * objects, we can't effectively subclass Graphics in the normal way to 
  24.  * specialize it.  Instead we create a wrapper around an existing Graphics 
  25.  * object.  For the most part, we just forward all the operations to the 
  26.  * wrapped object.  Only in a few places do we extend the API.<p>
  27.  *
  28.  * Routines that are not documented here are forwarded directly to the
  29.  * Graphics class (see that class for details).<p>
  30.  *
  31.  * @see java.awt.Graphics
  32.  * @author Scott Hudson
  33.  */
  34. public class drawable extends Graphics {
  35.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  36.  
  37.   /** Graphics object that we are a wrapper for */
  38.   protected Graphics g = null;
  39.  
  40.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  41.  
  42.   /** 
  43.    * Construct a drawable from a Graphics object.
  44.    * @param Graphics wrappee the object we are wrapper around.
  45.    */
  46.   public drawable(Graphics wrappee) 
  47.     {
  48.       g = wrappee;
  49.     }
  50.  
  51.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  52.  
  53.   /** 
  54.    * Override create() to create a new wrapper also.  Note: subclasses 
  55.    * will typically need to do this also.  
  56.    * @return Graphics a new drawable object copied from this one.
  57.    */
  58.   public Graphics create() 
  59.     {
  60.       return new drawable(g.create());
  61.     }
  62.  
  63.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  64.  
  65.   /** 
  66.    * Override create() to create a new wrapper also.  Note: subclasses 
  67.    * will typically need to do this also.
  68.    * 
  69.    * @param int x x component of origin of new drawable
  70.    * @param int y y component of origin of new drawable
  71.    * @param int w width of new drawable
  72.    * @param int h height of new drawable
  73.    * @return Graphics a new drawable object derived from this one.
  74.    */
  75.   public Graphics create(int x, int y, int w, int h) 
  76.     {
  77.       return new drawable(g.create(x,y,w,h));
  78.     }
  79.  
  80.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  81.  
  82.   /** 
  83.    * New version of create() that returns a drawable.  This does exactly
  84.    * the same thing as create(), but is just more accurate about its return
  85.    * type.  
  86.    * @return Graphics a new drawable object copied from this one.
  87.    */
  88.   public drawable copy() 
  89.     {
  90.       return new drawable(g.create());
  91.     }
  92.  
  93.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  94.  
  95.   /** 
  96.    * New version of create() that returns a drawable.  This does exactly
  97.    * the same thing as create(), but is just more accurate about its return
  98.    * type.  
  99.    * 
  100.    * @param int x x component of origin of new drawable
  101.    * @param int y y component of origin of new drawable
  102.    * @param int w width of new drawable
  103.    * @param int h height of new drawable
  104.    * @return Graphics a new drawable object derived from this one.
  105.    */
  106.   public drawable copy(int x, int y, int w, int h) 
  107.     {
  108.       return new drawable(g.create(x,y,w,h));
  109.     }
  110.  
  111.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  112.  
  113.   /** An observer object for effectively ignoring observation. */
  114.   protected static ignore_observer _ignore = new ignore_observer();
  115.  
  116.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  117.  
  118.   /** 
  119.    * Extended draw image that can deal with a loaded_image w/o an observer.
  120.    * If the image has not actually been loaded yet, this will block until
  121.    * it has.
  122.    *
  123.    * @param loaded_image img the image to be drawn.
  124.    * @param int          x   x position to place the image at.
  125.    * @param int          y   y position to place the image at.
  126.    * @return boolean undocumented return value from AWT drawImage() routine.
  127.    */
  128.   public boolean drawImage(loaded_image img, int x, int y)
  129.      {
  130.        return drawImage(img.image(),x,y,_ignore);
  131.  
  132.        /* note we use our own method here rather than the wrapped object's,
  133.     * so we can override in one place */
  134.      }
  135.  
  136.   /** 
  137.    * Extended draw image that can deal with a loaded_image w/o an observer.
  138.    * If the image has not actually been loaded yet, this will block until
  139.    * it has.
  140.    * 
  141.    * @param loaded_image img the image to be drawn.
  142.    * @param int          x   x position to place the image at.
  143.    * @param int          y   y position to place the image at.
  144.    * @param int          w   width image will be scaled to.
  145.    * @param int          h   height image will be scaled to.
  146.    * @return boolean undocumented return value from AWT drawImage() routine.
  147.    */
  148.   public boolean drawImage(loaded_image img, int x, int y, int w, int h)
  149.     {
  150.       return drawImage(img.image(),x,y,w,h,_ignore);
  151.     }
  152.  
  153.  
  154.   /** 
  155.    * Extended draw image that can deal with a loaded_image w/o an observer.
  156.    * If the image has not actually been loaded yet, this will block until
  157.    * it has.
  158.    * 
  159.    * @param loaded_image img     the image to be drawn.
  160.    * @param int          x       x position to place the image at.
  161.    * @param int          y       y position to place the image at.
  162.    * @param Color        bgcolor background color.
  163.    * @return boolean undocumented return value from AWT drawImage() routine.
  164.    */
  165.   public boolean drawImage(loaded_image img, int x, int y, Color bgcolor)
  166.     {
  167.       return drawImage(img.image(),x,y,bgcolor,_ignore);
  168.     }
  169.  
  170.  
  171.   /** Extended draw image that can deal with a loaded_image w/o an observer.
  172.    *  If the image has not actually been loaded yet, this will block until
  173.    *  it has.
  174.    *
  175.    * @param loaded_image img     the image to be drawn.
  176.    * @param int          x       x position to place the image at.
  177.    * @param int          y       y position to place the image at.
  178.    * @param int          w   width image will be scaled to.
  179.    * @param int          h   height image will be scaled to.
  180.    * @param Color        bgcolor background color.
  181.    * @return boolean undocumented return value from AWT drawImage() routine.
  182.    */
  183.   public boolean drawImage(
  184.     loaded_image img, 
  185.     int x, int y, 
  186.     int w, int h, 
  187.     Color bgcolor)
  188.     {
  189.       return drawImage(img.image(),x,y,w,h,bgcolor,_ignore);
  190.     }
  191.  
  192.   /** 
  193.    * subArctic style renaming of drawImage. 
  194.    * 
  195.    * @param loaded_image img the image to be drawn.
  196.    * @param int          x   x position to place the image at.
  197.    * @param int          y   y position to place the image at.
  198.    * @return boolean undocumented return value from AWT drawImage() routine.
  199.    */
  200.   public boolean draw_image(loaded_image img, int x, int y) 
  201.      {
  202.        return drawImage(img.image(),x,y,_ignore);
  203.  
  204.        /* note we use our own method here rather than the wrapped object's,
  205.     * so we can override in one place */
  206.      }
  207.  
  208.   /** 
  209.    * subArctic style renaming of drawImage.
  210.    * 
  211.    * @param loaded_image img the image to be drawn.
  212.    * @param int          x   x position to place the image at.
  213.    * @param int          y   y position to place the image at.
  214.    * @param int          w   width image will be scaled to.
  215.    * @param int          h   height image will be scaled to.
  216.    * @return boolean undocumented return value from AWT drawImage() routine.
  217.    */ 
  218.   public boolean draw_image(loaded_image img, int x, int y, int w, int h)
  219.     {
  220.       return drawImage(img.image(),x,y,w,h,_ignore);
  221.     }
  222.  
  223.   /** 
  224.    * subArctic style renaming of drawImage 
  225.    *
  226.    * @param loaded_image img     the image to be drawn.
  227.    * @param int          x       x position to place the image at.
  228.    * @param int          y       y position to place the image at.
  229.    * @param Color        bgcolor background color.
  230.    * @return boolean undocumented return value from AWT drawImage() routine.
  231.    */ 
  232.   public boolean draw_image(loaded_image img, int x, int y, Color bgcolor)
  233.     {
  234.       return drawImage(img.image(),x,y,bgcolor,_ignore);
  235.     }
  236.  
  237.  
  238.  
  239.   /** 
  240.    * subArctic style renaming of drawImage 
  241.    *
  242.    * @param loaded_image img     the image to be drawn.
  243.    * @param int          x       x position to place the image at.
  244.    * @param int          y       y position to place the image at.
  245.    * @param int          w   width image will be scaled to.
  246.    * @param int          h   height image will be scaled to.
  247.    * @param Color        bgcolor background color.
  248.    * @return boolean undocumented return value from AWT drawImage() routine.
  249.    */ 
  250.   public boolean draw_image(
  251.     loaded_image img, 
  252.     int x, int y, 
  253.     int w, int h, 
  254.     Color bgcolor)
  255.     {
  256.       return drawImage(img.image(),x,y,w,h,bgcolor,_ignore);
  257.     }
  258.  
  259.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  260.  
  261.   /** 
  262.    * Tiled drawing of a pattern image over an area.  The given image is drawn
  263.    * repeatedly to fill the given area.
  264.    *
  265.    * @param loaded_image pattern  the pattern to be tiled with the given space.
  266.    * @param int          x        x position to place the image at.
  267.    * @param int          y        y position to place the image at.
  268.    * @param int          w        width of area to tile.
  269.    * @param int          h        height of area to tile.
  270.    * @return boolean undocumented return value from AWT drawImage() routine.
  271.    */
  272.   public boolean tileImage(loaded_image pattern, int x, int y, int w, int h)
  273.     {
  274.       Image img  = pattern.image();
  275.       int size_x = pattern.width();
  276.       int size_y = pattern.height();
  277.       int xpt, ypt;
  278.       Graphics clipped_g;
  279.       boolean v = true;
  280.  
  281.       /* Build a copy of our Graphics object that clips to exactly the size
  282.        * we are clipping into 
  283.        */
  284.       clipped_g = g.create();
  285.       clipped_g.clipRect(x,y,w+1,h+1);
  286.  
  287.       /* loop over image area drawing tiles until we have filled it */
  288.       for (ypt = y; ypt-y < h; ypt += size_y)
  289.         for (xpt = x; xpt-x < w; xpt += size_x)
  290.       v = clipped_g.drawImage(img, xpt, ypt, _ignore);
  291.  
  292.       /* return the last return value we got */
  293.       return v;
  294.     }
  295.  
  296.   /**
  297.    * subArctic style renaming of tile_image 
  298.    *
  299.    * @param loaded_image pattern  the pattern to be tiled with the given space.
  300.    * @param int          x        x position to place the image at.
  301.    * @param int          y        y position to place the image at.
  302.    * @param int          w        width of area to tile.
  303.    * @param int          h        height of area to tile.
  304.    * @return boolean undocumented return value from AWT drawImage() routine.
  305.    */
  306.   public boolean tile_image(loaded_image pattern, int x, int y, int w, int h)
  307.     {
  308.       return tile_image(pattern, x, y, w, h);
  309.     }
  310.  
  311.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  312.  
  313.   /** 
  314.    * Draw a filled arrowhead polygon at the second end of the given line (this
  315.    * does not draw the line).<p>
  316.    *
  317.    * @param int    x1               first x coordinate of the line 
  318.    * @param int    y1               first y coordinate of the line 
  319.    * @param int    x2               second x coordinate of the line (arrow 
  320.    *                                head point goes here)
  321.    * @param int    y2               second y coordinate of the line (arrow 
  322.    *                                head point goes here)
  323.    * @param int    arrow_head_len   length of the sides of the arrow head
  324.    * @param int    arrow_head_angle angle between each side and the line in 
  325.    *                                degrees
  326.    * @param double arrow_inset      percent inset for base of arrow [0..1] 
  327.    *                                (values around 0.60 seem to work well).
  328.    */
  329.   public void fill_arrowhead(int x1, int y1, int x2, int y2, 
  330.     int arrow_head_len, int arrow_head_angle, double arrow_inset)
  331.     {
  332.       double dx, dy, len, sin_theta, cos_theta;
  333.       double pt1_x, pt1_y, pt2_x, pt2_y, pt3_x, pt3_y;
  334.       double ah_len = (double)arrow_head_len;
  335.       double ah_angle = Math.PI*((double)arrow_head_angle)/180.0;
  336.       int result1_x, result1_y, result2_x, result2_y, result3_x, result3_y;
  337.  
  338.       /* figure out the length of the line */
  339.       dx = (double)(x2-x1);
  340.       dy = (double)(y2-y1);
  341.       len = Math.sqrt(dx*dx+dy*dy);
  342.  
  343.       /* bail out now if its zero length */
  344.       if (len == 0) return;
  345.  
  346.       /* compute arrow head points if were were on line on x axis */
  347.       pt1_x = len - ah_len*Math.cos(ah_angle);
  348.       pt1_y = ah_len*Math.sin(ah_angle);
  349.       pt2_x = len - (len-pt1_x)*arrow_inset;
  350.       pt2_y = 0;
  351.       pt3_x = pt1_x;
  352.       pt3_y = -pt1_y;
  353.  
  354.       /* compute sin and cos of rotation to get line from x axis current pos */
  355.       sin_theta = dy / len;
  356.       cos_theta = dx / len;
  357.  
  358.       /* rotate and translate to get our final points */
  359.       result1_x = (int)(pt1_x*cos_theta - pt1_y*sin_theta + 0.5) + x1;
  360.       result1_y = (int)(pt1_x*sin_theta + pt1_y*cos_theta + 0.5) + y1;
  361.       result2_x = (int)(pt2_x*cos_theta - pt2_y*sin_theta + 0.5) + x1;
  362.       result2_y = (int)(pt2_x*sin_theta + pt2_y*cos_theta + 0.5) + y1;
  363.       result3_x = (int)(pt3_x*cos_theta - pt3_y*sin_theta + 0.5) + x1;
  364.       result3_y = (int)(pt3_x*sin_theta + pt3_y*cos_theta + 0.5) + y1;
  365.  
  366.       /* draw the arrow head polygon */
  367.       int xs[] = {x2, result1_x, result2_x, result3_x};
  368.       int ys[] = {y2, result1_y, result2_y, result3_y};
  369.       fill_polygon(xs,ys,4);
  370.     }
  371.  
  372.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  373.  
  374.   /** 
  375.    * Draw a filled arrowhead polygon (with good defaults) at the second end 
  376.    * of the given line (this does not draw the line).
  377.    *
  378.    * @param int x1 first x coordinate of the line 
  379.    * @param int y1 first y coordinate of the line 
  380.    * @param int x2 second x coordinate of the line (arrow head point goes here)
  381.    * @param int y2 second y coordinate of the line (arrow head point goes here)
  382.    */
  383.   public void fill_arrowhead(int x1, int y1, int x2, int y2)
  384.     {
  385.       fill_arrowhead(x1,y1,x2,y2, 20, 15, 0.60);
  386.     }
  387.  
  388.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  389.  
  390.   /** 
  391.    * Draw a hollow arrowhead (as lines) at the second end of the given line 
  392.    * (this does not draw the line).<p>
  393.    *
  394.    * @param int    x1               first x coordinate of the line. 
  395.    * @param int    y1               first y coordinate of the line.
  396.    * @param int    x2               second x coordinate of the line (arrow 
  397.    *                                head point goes here).
  398.    * @param int    y2               second y coordinate of the line (arrow 
  399.    *                                head point goes here).
  400.    * @param int    arrow_head_len   length of the sides of the arrow head.
  401.    * @param int    arrow_head_angle angle between each side and the line in 
  402.    *                                degrees.
  403.    * @param double arrow_inset      percent inset for base of arrow [0..1] 
  404.    *                                (values around 0.60 seem to work well).
  405.    */
  406.   public void draw_arrowhead(int x1, int y1, int x2, int y2, 
  407.     int arrow_head_len, int arrow_head_angle, double arrow_inset)
  408.     {
  409.       double dx, dy, len, sin_theta, cos_theta;
  410.       double pt1_x, pt1_y, pt2_x, pt2_y, pt3_x, pt3_y;
  411.       double ah_len = (double)arrow_head_len;
  412.       double ah_angle = Math.PI*((double)arrow_head_angle)/180.0;
  413.       int result1_x, result1_y, result2_x, result2_y, result3_x, result3_y;
  414.  
  415.       /* figure out the length of the line */
  416.       dx = (double)(x2-x1);
  417.       dy = (double)(y2-y1);
  418.       len = Math.sqrt(dx*dx+dy*dy);
  419.  
  420.       /* bail out now if its zero length */
  421.       if (len == 0) return;
  422.  
  423.       /* compute arrow head points if were were on line on x axis */
  424.       pt1_x = len - ah_len*Math.cos(ah_angle);
  425.       pt1_y = ah_len*Math.sin(ah_angle);
  426.       pt2_x = len - (len-pt1_x)*arrow_inset;
  427.       pt2_y = 0;
  428.       pt3_x = pt1_x;
  429.       pt3_y = -pt1_y;
  430.  
  431.       /* compute sin and cos of rotation to get line from x axis current pos */
  432.       sin_theta = dy / len;
  433.       cos_theta = dx / len;
  434.  
  435.       /* rotate and translate to get our final points */
  436.       result1_x = (int)(pt1_x*cos_theta - pt1_y*sin_theta + 0.5) + x1;
  437.       result1_y = (int)(pt1_x*sin_theta + pt1_y*cos_theta + 0.5) + y1;
  438.       result2_x = (int)(pt2_x*cos_theta - pt2_y*sin_theta + 0.5) + x1;
  439.       result2_y = (int)(pt2_x*sin_theta + pt2_y*cos_theta + 0.5) + y1;
  440.       result3_x = (int)(pt3_x*cos_theta - pt3_y*sin_theta + 0.5) + x1;
  441.       result3_y = (int)(pt3_x*sin_theta + pt3_y*cos_theta + 0.5) + y1;
  442.  
  443.       /* draw the arrow head lines */
  444.       draw_line(x2,y2,result1_x,result1_y);
  445.       draw_line(result1_x,result1_y, result2_x,result2_y);
  446.       draw_line(result2_x,result2_y, result3_x,result3_y);
  447.       draw_line(x2,y2,result3_x,result3_y);
  448.     }
  449.  
  450.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  451.  
  452.   /** 
  453.    * Draw a hollow arrowhead (as lines) at the second end of the given line 
  454.    * (this does not draw the line). This version provides good defaults for
  455.    * the arrow size and shape.<p>
  456.    *
  457.    * @param int x1 first x coordinate of the line 
  458.    * @param int y1 first y coordinate of the line 
  459.    * @param int x2 second x coordinate of the line (arrow head point goes here)
  460.    * @param int y2 second y coordinate of the line (arrow head point goes here)
  461.    */
  462.   public void draw_arrowhead(int x1, int y1, int x2, int y2)
  463.     {
  464.       draw_arrowhead(x1,y1,x2,y2, 20, 15, 0.60);
  465.     }
  466.  
  467.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  468.  
  469.   /**
  470.    * Find the min and max points bounding the arrowhead that would be drawn
  471.    * at the second point on the given line. <p> 
  472.    * 
  473.    * @param int x1 first x coordinate of the line 
  474.    * @param int y1 first y coordinate of the line 
  475.    * @param int x2 second x coordinate of the line (arrow head point goes here)
  476.    * @param int y2 second y coordinate of the line (arrow head point goes here)
  477.    * @param int arrow_head_len length of the sides of the arrow head
  478.    * @param int arrow_head_angle angle between each side and the line in degrees
  479.    * @param double arrow_inset percent inset for base of arrow [0..1]
  480.    * @param Point min_pt returns holding the min x,y of the bound
  481.    * @param Point max_pt returns holding the max x,y of the bound
  482.    */
  483.   public void arrowhead_bound( int x1, int y1, int x2, int y2, 
  484.     int arrow_head_len, int arrow_head_angle, double arrow_inset,
  485.     Point min_pt, Point max_pt)
  486.     {
  487.       double dx, dy, len, sin_theta, cos_theta;
  488.       double pt1_x, pt1_y, pt2_x, pt2_y, pt3_x, pt3_y;
  489.       double ah_len = (double)arrow_head_len;
  490.       double ah_angle = Math.PI*((double)arrow_head_angle)/180.0;
  491.       int result1_x, result1_y, result2_x, result2_y, result3_x, result3_y;
  492.       int max_x, max_y, min_x, min_y;
  493.  
  494.       /* figure out the length of the line */
  495.       dx = (double)(x2-x1);
  496.       dy = (double)(y2-y1);
  497.       len = Math.sqrt(dx*dx+dy*dy);
  498.  
  499.       /* bail out now if its zero length */
  500.       if (len == 0)
  501.     {
  502.       min_pt.x = max_pt.x = x1;
  503.       min_pt.y = max_pt.y = y1;
  504.       return;
  505.     }
  506.  
  507.       /* compute arrow head points if were were on line on x axis */
  508.       pt1_x = len - ah_len*Math.cos(ah_angle);
  509.       pt1_y = ah_len*Math.sin(ah_angle);
  510.       pt2_x = len - (len-pt1_x)*arrow_inset;
  511.       pt2_y = 0;
  512.       pt3_x = pt1_x;
  513.       pt3_y = -pt1_y;
  514.  
  515.       /* compute sin and cos of rotation to get line from x axis current pos */
  516.       sin_theta = dy / len;
  517.       cos_theta = dx / len;
  518.  
  519.       /* rotate and translate to get our final points */
  520.       result1_x = (int)(pt1_x*cos_theta - pt1_y*sin_theta + 0.5) + x1;
  521.       result1_y = (int)(pt1_x*sin_theta + pt1_y*cos_theta + 0.5) + y1;
  522.       result2_x = (int)(pt2_x*cos_theta - pt2_y*sin_theta + 0.5) + x1;
  523.       result2_y = (int)(pt2_x*sin_theta + pt2_y*cos_theta + 0.5) + y1;
  524.       result3_x = (int)(pt3_x*cos_theta - pt3_y*sin_theta + 0.5) + x1;
  525.       result3_y = (int)(pt3_x*sin_theta + pt3_y*cos_theta + 0.5) + y1;
  526.  
  527.       /* compute min and max */
  528.       min_x = x2;
  529.       if (min_x > result1_x) min_x = result1_x;
  530.       if (min_x > result2_x) min_x = result2_x;
  531.       if (min_x > result3_x) min_x = result3_x;
  532.       min_y = y2;
  533.       if (min_y > result1_y) min_y = result1_y;
  534.       if (min_y > result2_y) min_y = result2_y;
  535.       if (min_y > result3_y) min_y = result3_y;
  536.       max_x = x2;
  537.       if (max_x < result1_x) max_x = result1_x;
  538.       if (max_x < result2_x) max_x = result2_x;
  539.       if (max_x < result3_x) max_x = result3_x;
  540.       max_y = y2;
  541.       if (max_y < result1_y) max_y = result1_y;
  542.       if (max_y < result2_y) max_y = result2_y;
  543.       if (max_y < result3_y) max_y = result3_y;
  544.  
  545.       /* write back results */
  546.       min_pt.x = min_x; min_pt.y = min_y;
  547.       max_pt.x = max_x; max_pt.y = max_y;
  548.     }
  549.  
  550.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  551.  
  552.   /**
  553.    * Find the min and max points bounding the arrowhead that would be drawn
  554.    * at the second point on the given line. <p> 
  555.    * 
  556.    * @param int x1 first x coordinate of the line 
  557.    * @param int y1 first y coordinate of the line 
  558.    * @param int x2 second x coordinate of the line (arrow head point goes here)
  559.    * @param int y2 second y coordinate of the line (arrow head point goes here)
  560.    * @param Point min_pt returns holding the min x,y of the bound
  561.    * @param Point max_pt returns holding the max x,y of the bound
  562.    */
  563.   public void arrowhead_bound( int x1, int y1, int x2, int y2, 
  564.     Point min_pt, Point max_pt)
  565.     {
  566.       arrowhead_bound(x1,y1,x2,y2,20,15,0.60,min_pt,max_pt);
  567.     }
  568.  
  569.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  570.  
  571.   /* Just forward all the rest of the operations... */
  572.   public void translate(int x, int y) {g.translate(x,y);}
  573.   public Color getColor() {return g.getColor();}
  574.   public Color get_color() {return g.getColor();}
  575.   public void setColor(Color c) {g.setColor(c);}
  576.   public void set_color(Color c) {g.setColor(c);}
  577.   public void setPaintMode() {g.setPaintMode();}
  578.   public void set_paint_mode() {g.setPaintMode();}
  579.   public void setXORMode(Color c) {g.setXORMode(c);}
  580.   public void set_XOR_mode(Color c) {g.setXORMode(c);}
  581.   public Font getFont() {return g.getFont();}
  582.   public Font get_font() {return g.getFont();}
  583.   public void setFont(Font font) {g.setFont(font);}
  584.   public void set_font(Font font) {g.setFont(font);}
  585.   public FontMetrics getFontMetrics() {return g.getFontMetrics();}
  586.   public FontMetrics get_font_metrics() {return g.getFontMetrics();}
  587.   public FontMetrics getFontMetrics(Font f) {return g.getFontMetrics(f);}
  588.   public FontMetrics get_font_metrics(Font f) {return g.getFontMetrics(f);}
  589.   public Rectangle getClipRect() {return g.getClipRect();}
  590.   public Rectangle get_clip_rect() {return g.getClipRect();}
  591.   public void clipRect(int x, int y, int w, int h) {g.clipRect(x,y,w,h);}
  592.   public void clip_rect(int x, int y, int w, int h) {g.clipRect(x,y,w,h);}
  593.   public void copyArea(int x, int y, int w, int h, int dx, int dy)
  594.     {g.copyArea(x,y,w,h,dx,dy);}
  595.   public void copy_area(int x, int y, int w, int h, int dx, int dy)
  596.     {g.copyArea(x,y,w,h,dx,dy);}
  597.   public void drawLine(int x1, int y1, int x2, int y2)
  598.     {g.drawLine(x1,y1,x2,y2);}
  599.   public void draw_line(int x1, int y1, int x2, int y2)
  600.     {g.drawLine(x1,y1,x2,y2);}
  601.   public void fillRect(int x, int y, int w, int h) {g.fillRect(x,y,w,h);}
  602.   public void fill_rect(int x, int y, int w, int h) {g.fillRect(x,y,w,h);}
  603.   public void drawRect(int x, int y, int w, int h) {g.drawRect(x,y,w,h);}
  604.   public void draw_rect(int x, int y, int w, int h) {g.drawRect(x,y,w,h);}
  605.   public void clearRect(int x, int y, int w, int h) {g.clearRect(x,y,w,h);}
  606.   public void clear_rect(int x, int y, int w, int h) {g.clearRect(x,y,w,h);}
  607.   public void drawRoundRect(int x, int y, int w, int h, int arcw, int arch)
  608.     {g.drawRoundRect(x,y,w,h,arcw,arch);}
  609.   public void draw_round_rect(int x, int y, int w, int h, int arcw, int arch)
  610.     {g.drawRoundRect(x,y,w,h,arcw,arch);}
  611.   public void fillRoundRect(int x, int y, int w, int h, int arcw, int arch)
  612.     {g.fillRoundRect(x,y,w,h,arcw,arch);}
  613.   public void fill_round_rect(int x, int y, int w, int h, int arcw, int arch)
  614.     {g.fillRoundRect(x,y,w,h,arcw,arch);}
  615.   public void draw3DRect(int x, int y, int w, int h, boolean raised)
  616.     {g.draw3DRect(x,y,w,h,raised);}
  617.   public void draw_3D_rect(int x, int y, int w, int h, boolean raised)
  618.     {g.draw3DRect(x,y,w,h,raised);}
  619.   public void fill3DRect(int x, int y, int w, int h, boolean raised) 
  620.     {g.fill3DRect(x,y,w,h,raised);}
  621.   public void fill_3D_rect(int x, int y, int w, int h, boolean raised) 
  622.     {g.fill3DRect(x,y,w,h,raised);}
  623.   public void drawOval(int x, int y, int w, int h) {g.drawOval(x,y,w,h);}
  624.   public void draw_oval(int x, int y, int w, int h) {g.drawOval(x,y,w,h);}
  625.   public void fillOval(int x, int y, int w, int h) {g.fillOval(x,y,w,h);}
  626.   public void fill_oval(int x, int y, int w, int h) {g.fillOval(x,y,w,h);}
  627.   public void drawArc(int x, int y, int w, int h, int start_ang, int arc_ang)
  628.     {g.drawArc(x,y,w,h,start_ang, arc_ang);}
  629.   public void draw_arc(int x, int y, int w, int h, int start_ang, int arc_ang)
  630.     {g.drawArc(x,y,w,h,start_ang, arc_ang);}
  631.   public void fillArc(int x, int y, int w, int h, int start_ang, int arc_ang)
  632.     {g.fillArc(x,y,w,h,start_ang,arc_ang);}
  633.   public void fill_arc(int x, int y, int w, int h, int start_ang, int arc_ang)
  634.     {g.fillArc(x,y,w,h,start_ang,arc_ang);}
  635.   public void drawPolygon(int xp[], int yp[], int np) 
  636.     {g.drawPolygon(xp,yp,np);}
  637.   public void draw_polygon(int xp[], int yp[], int np) 
  638.     {g.drawPolygon(xp,yp,np);}
  639.   public void drawPolygon(Polygon p) {g.drawPolygon(p);}
  640.   public void draw_polygon(Polygon p) {g.drawPolygon(p);}
  641.   public void fillPolygon(int xp[], int yp[], int np) 
  642.     {g.fillPolygon(xp,yp,np);}
  643.   public void fill_polygon(int xp[], int yp[], int np) 
  644.     {g.fillPolygon(xp,yp,np);}
  645.   public void fillPolygon(Polygon p) {g.fillPolygon(p);}
  646.   public void fill_polygon(Polygon p) {g.fillPolygon(p);}
  647.   public void drawString(String str, int x, int y) {g.drawString(str,x,y);}
  648.   public void draw_string(String str, int x, int y) {g.drawString(str,x,y);}
  649.   public void drawChars(char data[], int off, int len, int x, int y)
  650.     {g.drawChars(data,off,len,x,y);}
  651.   public void draw_chars(char data[], int off, int len, int x, int y)
  652.     {g.drawChars(data,off,len,x,y);}
  653.   public void drawBytes(byte data[], int off, int len, int x, int y) 
  654.     {g.drawBytes(data,off,len,x,y);}
  655.   public void draw_bytes(byte data[], int off, int len, int x, int y) 
  656.     {g.drawBytes(data,off,len,x,y);}
  657.   public boolean drawImage(Image img, int x, int y, ImageObserver observer)
  658.     {return g.drawImage(img,x,y,observer);}
  659.   public boolean draw_image(Image img, int x, int y, ImageObserver observer)
  660.     {return g.drawImage(img,x,y,observer);}
  661.   public boolean drawImage(Image img, int x, int y, int w, int h, 
  662.                                                           ImageObserver obs)
  663.     {return g.drawImage(img,x,y,w,h,obs);}
  664.   public boolean draw_image(Image img, int x, int y, int w, int h, 
  665.                                                           ImageObserver obs)
  666.     {return g.drawImage(img,x,y,w,h,obs);}
  667.   public boolean drawImage(Image img, int x, int y, Color bgcolor,
  668.                                           ImageObserver obs) 
  669.     {return g.drawImage(img,x,y,bgcolor,obs);}
  670.   public boolean draw_image(Image img, int x, int y, Color bgcolor,
  671.                                           ImageObserver obs) 
  672.     {return g.drawImage(img,x,y,bgcolor,obs);}
  673.   public boolean drawImage(Image img, int x, int y, int w, int h, Color bgcolor,
  674.                                           ImageObserver obs)
  675.     {return g.drawImage(img,x,y,w,h,bgcolor,obs);}
  676.   public boolean draw_image(Image img, int x, int y, int w, int h, 
  677.                         Color bgcolor, ImageObserver obs)
  678.     {return g.drawImage(img,x,y,w,h,bgcolor,obs);}
  679.   public void dispose() {g.dispose();}
  680.   public void finalize() {g.finalize();} 
  681.  
  682.   /** Convert to a human readable string. */
  683.   public String toString() 
  684.     {
  685.       return "sub_arctic.output.drawable{"+g.toString()+"}";
  686.     }    
  687. }
  688. /*=========================== COPYRIGHT NOTICE ===========================
  689.  
  690. This file is part of the subArctic user interface toolkit.
  691.  
  692. Copyright (c) 1996 Scott Hudson and Ian Smith
  693. All rights reserved.
  694.  
  695. The subArctic system is freely available for most uses under the terms
  696. and conditions described in 
  697.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  698. and appearing in full in the lib/interactor.java source file.
  699.  
  700. The current release and additional information about this software can be 
  701. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  702.  
  703. ========================================================================*/
  704.